#include <iostream>
#include <ctime>
#include "ThreadPool.hpp"
 #include "Task.hpp"

// pthread_spinlock_t slock;

int main(){
    //单例对象
    std::cout<<"process runn..."<<std::endl;
    sleep(3);
    ThreadPool<Task>::GetInstance()->Start();//创建线程池,这是一个单例对象，之前是信号量控制的(product_consumer_model)
    srand(time(nullptr)^getpid());
    while(true){
        int x=rand()%10+1;
        usleep(10);
        int y = rand()%5;
        char op = opers[rand()%opers.size()];
        
        Task t(x,y,op);
        ThreadPool<Task>::GetInstance()->Push(t); //线程调用
        //2.交给线程池处理
        std::cout<<"main thread make task: "<<t.GetTask()<<std::endl;
        
        sleep(1);
    }
    return 0;
}

